/*
 * @Author: szx
 * @Date: 2022-05-16 14:05:49
 * @LastEditTime: 2022-05-16 14:15:05
 * @Description:
 * @FilePath: \leetcode\面试题\03\06\06.js
 */
var AnimalShelf = function () {
    this.cat = [];
    this.dog = [];
    // this.any = [];
};

/**
 * @param {number[]} animal
 * @return {void}
 */
AnimalShelf.prototype.enqueue = function (animal) {
    if (animal[1] == 0) this.cat.push(animal[0]);
    else this.dog.push(animal[0]);
    // this.any.push(animal[0]);
};

/**
 * @return {number[]}
 */
AnimalShelf.prototype.dequeueAny = function () {
    if (!this.cat.length && !this.dog.length) return [-1, -1];
    if (!this.cat.length && this.dog.length) return [this.dog.pop(), 1];
    if (this.cat.length && !this.dog.length) return [this.cat.pop(), 0];
    if (this.cat[0] < this.dog[0]) return [this.cat.pop(), 0];
    else return [this.dog.pop(), 1];
};

/**
 * @return {number[]}
 */
AnimalShelf.prototype.dequeueDog = function () {
    if (this.dog.length) return [this.dog.pop(), 1];
    else return [-1, -1];
};

/**
 * @return {number[]}
 */
AnimalShelf.prototype.dequeueCat = function () {
    if (this.cat.length) return [this.cat.pop(), 0];
    else return [-1, -1];
};
